package com.dc.controller;

import com.dc.annotation.Log;
import com.dc.common.ResponseResultVO;
import com.dc.entity.ro.RepairWorkOrderRO;
import com.dc.entity.vo.RepairVO;
import com.dc.service.RepairWorkOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

@Api(tags = "报修工单表管理")
@RestController
@RequestMapping("/repairWorkOrder")
public class RepairWorkOrderController {

    @Resource
    private RepairWorkOrderService repairWorkOrderService;

    @Log(title = "报修工单表管理", businessDesc = "增加")
    @ApiOperation(value = "增加", notes = "增加")
    @PostMapping("/insertRepairWorkOrder")
    public ResponseResultVO insertRepairWorkOrder(@RequestBody RepairWorkOrderRO ro) {
        return repairWorkOrderService.insertRepairWorkOrder(ro);
    }

    @Log(title = "报修工单表管理", businessDesc = "修改")
    @ApiOperation(value = "修改", notes = "修改")
    @PostMapping("/updateRepairWorkOrder")
    public ResponseResultVO updateRepairWorkOrder(@RequestBody RepairWorkOrderRO ro) {
        return repairWorkOrderService.updateRepairWorkOrder(ro);
    }

    @Log(title = "报修工单表管理", businessDesc = "删除")
    @ApiOperation(value = "删除", notes = "删除")
    @GetMapping("/deleteRepairWorkOrder")
    public ResponseResultVO deleteRepairWorkOrder(@RequestParam String id) {
        return repairWorkOrderService.deleteRepairWorkOrder(id);
    }

    @ApiOperation(value = "查询列表", notes = "查询列表")
    @PostMapping("/selectRepairWorkOrderList")
    public ResponseResultVO<RepairVO> selectRepairWorkOrderList(@RequestBody RepairWorkOrderRO ro) {
        return repairWorkOrderService.selectRepairWorkOrderList(ro);
    }

    @ApiOperation(value = "列表导出", notes = "列表导出")
    @PostMapping("/repairWorkOrderRecordExport")
    public void repairWorkOrderRecordExport(HttpServletResponse response, @RequestBody RepairWorkOrderRO ro) {
        repairWorkOrderService.repairWorkOrderRecordExport(response, ro);
    }

    @ApiOperation(value = "详情信息", notes = "详情信息")
    @GetMapping("/selectRepairDetails")
    public ResponseResultVO<RepairVO> selectRepairDetails(@RequestParam String id) {
        return ResponseResultVO.successResult(repairWorkOrderService.getById(id));
    }

}
